package oj;

import java.util.Scanner;

public class L {


    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int count = in.nextInt();
        int c = 1;
        while (count-- > 0) {
            int anInt = in.nextInt();
            int total = 0;
            Integer[] arr = new Integer[anInt];
            while (anInt-- > 0) {
                arr[total] = in.nextInt();
                total++;
            }
            int sum = 0;
//            for (int i = 0, k = arr.length - 1; i < arr.length; i++, k--) {
            int left = left(arr, true, arr.length - 1, 0);
            int reight = reight(arr, true, 0, 0);
            sum = Math.max(left, reight);
//            }
            System.out.printf("Case #%d: %d\n", c, sum);
            c++;
        }
    }

    public static int left(Integer[] arr, boolean bo, int start, int moneny) {
        if (bo) {
            moneny += arr[start] / 10000;
            bo = false;
        }
        if (start - 1 < 0) {
            return moneny;
        }
        // 当前
        int ai = arr[start] % 10000;

        // 前一个
        int lbi = arr[start - 1] / 10000;
        int lai = arr[start - 1] % 10000;

        if (lai >= ai) {
            return left(arr, bo, start - 1, moneny + lbi);
        }
        return moneny;

    }


    public static int reight(Integer[] arr, boolean bo, int start, int moneny) {
        if (bo) {
            moneny += arr[start] / 10000;
            bo = false;
        }
        if (start + 1 >= arr.length) {
            return moneny;
        }
        // 当前
        int ai = arr[start] % 10000;
        // 后一个
        int lbi = arr[start + 1] / 10000;
        int lai = arr[start + 1] % 10000;

        if (lai >= ai) {
            return reight(arr, bo, start + 1, moneny + lbi);
        }
        return moneny;

    }
}
